package com.tanhua.app.controller;

import com.tanhua.app.service.MakeFriendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class MakeFriendController {

    @Autowired
    private MakeFriendService makeFriendService;

    @GetMapping(value = "/tanhua/todayBest", name = "今日佳人")
    public ResponseEntity findTodayBest() {
        return makeFriendService.findTodayBest();
    }

    @GetMapping(value = "/tanhua/recommendation", name = "推荐用户")
    public ResponseEntity recommendation(
            @RequestParam(value = "page", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pagesize", defaultValue = "10") Integer pageSize) {
        return makeFriendService.recommendation(pageNum, pageSize);
    }

    @GetMapping(value = "/movements/visitors", name = "最近访问")
    public ResponseEntity visitors() {
        return makeFriendService.visitors();
    }

    @GetMapping(value = "/tanhua/{bestUserId}/personalInfo", name = "佳人详情")
    public ResponseEntity personalInfo(@PathVariable Long bestUserId) {
        return makeFriendService.personalInfo(bestUserId);
    }

    @GetMapping(value = "/tanhua/strangerQuestions", name = "查询陌生人问题")
    public ResponseEntity findQuestionsByUserId(Long userId) {
        String text = makeFriendService.findQuestionsByUserId(userId);
        return ResponseEntity.ok(text);
    }

    @PostMapping(value = "/tanhua/strangerQuestions", name = "回答陌生人问题")
    public ResponseEntity replyQuestions(@RequestBody Map<String, String> param) {
        String userId = param.get("userId");
        String reply = param.get("reply");

        return makeFriendService.replyQuestions(userId, reply);
    }

    @GetMapping(value = "/tanhua/cards", name = "查询推荐用户卡牌")
    public ResponseEntity findCards() {
        return makeFriendService.findCards();
    }

    @GetMapping(value = "/tanhua/{likeUserId}/love", name = "喜欢用户")
    public ResponseEntity likeUser(@PathVariable Long likeUserId) {
        return makeFriendService.likeUser(likeUserId);
    }

    @GetMapping(value = "/tanhua/{likeUserId}/unlove", name = "不喜欢用户")
    public ResponseEntity unLikeUser(@PathVariable Long likeUserId) {
        return makeFriendService.unLikeUser(likeUserId);
    }

    @GetMapping(value = "/tanhua/search", name = "搜附近")
    public ResponseEntity searchNearUser(String gender, Long distance) {
        return makeFriendService.searchNearUser(gender, distance);
    }
}
